package com.company.project.service.impl;

import com.company.project.core.Page;
import com.company.project.core.Result;
import com.company.project.core.ResultGenerator;
import com.company.project.dao.JobMapper;
import com.company.project.model.College;
import com.company.project.model.Job;
import com.company.project.model.SysUser;
import com.company.project.service.JobService;
import com.company.project.core.AbstractService;
import org.apache.shiro.SecurityUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;


/**
 * Created by CodeGenerator on 2020/04/21.
 */
@Service
@Transactional
public class JobServiceImpl extends AbstractService<Job> implements JobService {
    @Resource
    private JobMapper jobMapper;

    /**
     * 查询岗位列表
     *
     * @param pageInfo
     * @return
     */
    @Override
    public Result queryJobList(Page pageInfo) {
        SysUser userInfo = (SysUser) SecurityUtils.getSubject().getPrincipal();
        Integer count = jobMapper.countForPage(userInfo.getId());
        pageInfo.setAllRow(count);
        List<College> collegeList  = jobMapper.selectForPage(userInfo.getId(),pageInfo.getStart(), pageInfo.getSize());
        return ResultGenerator.genSuccessResult(collegeList);
    }

    @Override
    public Result changeStatus(Integer id, Integer status) {
        jobMapper.changeStatus(id,status);
        return ResultGenerator.genSuccessResult();
    }
}
